<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js.js" type="text/javascript" ></script>
    <script type="text/javascript">
        window.onload = function () {//不加window.onload放在HTML元素下面才有效
            var txt = document.getElementById('txt');
            var btn = document.getElementById('btn');
            var div1 = document.getElementById('div1');
            btn.onclick = function () {
                div1.innerHTML = txt.value;
            }
        }
    </script>
</head>
<body>
<input type="text" id="txt">
<input type="button" id="btn" value="提交">
<div id="div1"></div>
</body>

</html>
